from django.db import models
from django.contrib.auth.models import User

class Greeting(models.Model):
   author = models.ForeignKey(User, null=True, blank=True)
   content = models.TextField()
   date = models.DateTimeField(auto_now_add=True)
   
class MatchMeUser(models.Model):
   matchme_user = models.ForeignKey(User, blank=False)
   phone_number = models.CharField(max_length=10, blank=False)
   profile_pic = models.FileField(upload_to='images')
   
class Friend(models.Model):
   userid1 = models.ForeignKey(User, blank=False, related_name="friend_user")
   userid2 = models.ForeignKey(User, blank=False, related_name="friend_otherUser")
   
class Alert(models.Model):
   ALERTTYPE_CHOICE = (
      (u'C', u'Comment'),
      (u'F', u'Friend Request'),
      (u'M', u'MatchMe Request'),
   )
   userid1 = models.ForeignKey(User, blank=False, related_name="alert_user")
   userid2 = models.ForeignKey(User, blank=False, related_name="alert_otherUser")
   type = models.CharField(max_length=1, choices=ALERTTYPE_CHOICE, blank=False)
   typeid = models.IntegerField()
   created_on = models.DateTimeField(auto_now_add=True)
   
class Post(models.Model):
   POSTSTATUS_CHOICE = (
      (u'C', u'Completed'),
      (u'P', u'Pending'),
   )
   pic1 = models.CharField(max_length=150)
   userid1 = models.ForeignKey(User, blank=False, related_name="post_user")
   userid2 = models.ForeignKey(User, related_name="post_otherUser")
   location1 = models.CharField(max_length=150)
   location2 = models.CharField(max_length=150)
   status = models.CharField(max_length=1, choices=POSTSTATUS_CHOICE)
   time1 = models.DateTimeField(auto_now_add=True)
   time2 = models.DateTimeField()
   description1 =  models.CharField(max_length=150)
   description2 =  models.CharField(max_length=150)
   
class Like(models.Model):
   postid = models.ForeignKey(Post, blank=False, primary_key=True)
   userid = models.ForeignKey(User, blank=False, primary_key=True)
   
class Comment(models.Model):
   userid = models.ForeignKey(User, blank=False)
   postid = models.ForeignKey(Post, blank=False)
   description = models.CharField(blank=False,max_length=150)
   time1 = models.DateTimeField(auto_now_add=True,blank=False)
   
class Tag(models.Model):
   postid = models.ForeignKey(Post, blank=False, primary_key=True)
   userid = models.ForeignKey(User, blank=False, primary_key=True)
